package com.kaisa.activity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.kaisa.activity.R;
import com.kaisa.activity.bean.ShipListBean;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.List;

/**
 * Created by Administrator on 2015/12/13.
 */
public class ShiListAdapter extends AppBaseAdapter<ShipListBean.EntitysEntity>{

    public ShiListAdapter(List<ShipListBean.EntitysEntity> list, Context context) {
        super(list, context);
        inflater = LayoutInflater.from(context);
    }


    @Override
    public View getItemView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_shiplist,parent,false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        //映射数据
        x.image().bind(holder.img,list.get(position).getPictureUrlForHaiHang());
        holder.lineName.setText(list.get(position).getLineName());
        holder.departure.setText(list.get(position).getDeparture()+"出发");
        holder.price.setText(list.get(position).getPrice());
        return convertView;
    }

    public static class ViewHolder extends BaseViewHolder{
        @ViewInject(R.id.iv_shiplist_img)
        private ImageView img;
        @ViewInject(R.id.tv_shiplist_lineName)
        private TextView lineName;
        @ViewInject(R.id.tv_shiplsit_departure)
        private TextView departure;
        @ViewInject(R.id.tv_shiplist_price)
        private TextView price;



        public ViewHolder(View convertView) {
            super(convertView);
            x.view().inject(this,convertView);
        }
    }
}
